package interfaz;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLayeredPane;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.JScrollPane;
import java.awt.Toolkit;
import java.awt.Component;
import javax.swing.JTextArea;
import java.awt.Cursor;
import java.awt.Font;

public class Error extends JDialog {

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			Error dialog = new Error("Ho");
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
//	public Error() {
//		setResizable(false);
//		setIconImage(Toolkit.getDefaultToolkit().getImage(Error.class.getResource("/assets/Iconos/Warning.png")));
//		setBounds(100, 100, 530, 235);
//		
//		JLayeredPane layeredPane = new JLayeredPane();
//		GroupLayout groupLayout = new GroupLayout(getContentPane());
//		groupLayout.setHorizontalGroup(
//			groupLayout.createParallelGroup(Alignment.LEADING)
//				.addComponent(layeredPane, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE)
//		);
//		groupLayout.setVerticalGroup(
//			groupLayout.createParallelGroup(Alignment.LEADING)
//				.addComponent(layeredPane, GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
//		);
//		
//		JLabel lblWarning = new JLabel("");
//		lblWarning.setIcon(new ImageIcon(Error.class.getResource("/assets/Iconos/Warning.png")));
//		lblWarning.setBounds(10, 49, 118, 96);
//		layeredPane.add(lblWarning);
//		
//		JLabel lblMsgError = new JLabel("");
//		lblMsgError.setIcon(new ImageIcon(Error.class.getResource("/assets/Iconos/msgError.png")));
//		lblMsgError.setBounds(248, 11, 157, 42);
//		layeredPane.add(lblMsgError);
//		
//	}
	
	public Error(String mensaje) {
		setResizable(false);
		setIconImage(Toolkit.getDefaultToolkit().getImage(Error.class.getResource("/assets/warning-sign2.png")));
		setBounds(100, 100, 502, 235);
		
		JLayeredPane layeredPane = new JLayeredPane();
		GroupLayout groupLayout = new GroupLayout(getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addComponent(layeredPane, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE)
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addComponent(layeredPane, GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
		);
		
		JLabel lblWarning = new JLabel("");
		lblWarning.setIcon(new ImageIcon(Error.class.getResource("/assets/warning-sign2.png")));
		lblWarning.setBounds(10, 49, 118, 96);
		layeredPane.add(lblWarning);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(156, 38, 311, 122);
		layeredPane.add(scrollPane);
		
		JTextArea textError = new JTextArea(mensaje);
		scrollPane.setViewportView(textError);
		textError.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
		textError.setEditable(false);
		
		JLabel lblError = new JLabel("Error");
		lblError.setFont(new Font("Tahoma", Font.BOLD, 15));
		lblError.setBounds(276, 13, 46, 14);
		layeredPane.add(lblError);
		getContentPane().setLayout(groupLayout);
	}
	
}
